<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户文章</title>
    <link href="__STATIC__/admin/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="__STATIC__/admin/css/style.css" />
    <link href="__STATIC__/admin/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace.min.css" />
    <link rel="stylesheet" href="__STATIC__/admin/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="__STATIC__/admin/js/jquery-1.9.1.min.js"></script>
    <script src="__STATIC__/admin/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="__STATIC__/admin/assets/js/typeahead-bs2.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.min.js"></script>
    <script src="__STATIC__/admin/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/js/lrtk.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/layer/layer.js" type="text/javascript"></script>
    <script src="__STATIC__/admin/assets/laydate/laydate.js" type="text/javascript"></script>
</head>

<body>

<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">
            <form action="{:url('question/index')}" method="get">
                <div class="search_style">
                    <ul class="search_content clearfix">
                        <li>
                            <label class="l_f">输入搜索关键字:</label>
                            <input name="keyword" type="text" class="text_add"
                                   placeholder="文章标题搜索"
                                   value=""/>
                        </li>

                        <li style="width:90px;">
                            <button type="submit" class="btn_search">
                                <i class="fa fa-search"></i>查询
                            </button>
                        </li>
                    </ul>
                </div>
            </form>
            <!--操作-->
            <div class="border clearfix">
                <span class="l_f">
                </span>
            </div>
            <!--管理员列表-->
            <div class="clearfix">
                <div class="table_menu_list">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>

                                <th width="80px">编号</th>
                                <th width="250px">文章标题</th>
                                <th width="100px">发布文章用户</th>
                                <th width="100px">点击</th>
                                <th width="100px">是否热门</th>
                                <th width="100px">发布时间</th>
                                <th width="70px">状态</th>
                                <th width="200px">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {foreach $question as $item}
                            <tr>
                                <td>{$item.q_id}</td>
                                <td>{$item.q_title}</td>
                                <td>{$item.user_name}</td>
                                <td>{$item.click}</td>
                                <td>{$item.focus?'热门':'不热门'}</td>
                                <td>{$item.create_time|date="Y-m-d H:i:s",###}</td>
                                <td class="audit">{if condition='$item.audit==0'}未通过{elseif condition='$item.audit==1'}通过{else}待审核{/if}</td>

                                <td>
                                    <a title="编辑" href="{:url('question/edite',['q_id'=>$item.q_id])}"
                                       class="btn btn-xs btn-info">
                                        <i class="fa fa-edit bigger-120"></i>
                                    </a>
                                    <a title="审核" href="javascript:;" data-id="{$item.q_id}"
                                       class="btn btn-xs btn-warning question_adopt">
                                        通过
                                    </a>
                                    <a title="审核" href="javascript:;" data-id="{$item.q_id}"
                                       class="btn btn-xs btn-warning question_nopass">
                                        不通过
                                    </a>
                                </td>
                            </tr>
                            {/foreach}

                            </tbody>
                        </table>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="dataTables_info">共 2 条</div>
                </div>
                <div class="col-sm-6">
                    <div class="dataTables_info">{$question->render()}</div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    /*确定删除*/
    /*function confirm_msg(obj) {
        var url = $(obj).attr('url');
        layer.confirm('确认要删除吗？', function(index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {
                icon: 1,
                time: 1000
            });
        });
    }
    $(function(){
        $('table th input:checkbox').on('click', function() {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox').each(function() {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
            });
        });
        laydate({
            elem: '#start',
            event: 'focus'
        });
    })*/
    //单行删除
    $('.question_adopt').on('click',function () {
        var that=$(this);


            del(that);
            layer.close(index);

    });
    function del(that){
        var q_id=$(that).data('id');
        var url="{:url('question/adopt')}";
        var data={q_id:q_id};
        $.post(url,data,function (res) {
            if(res.status==1){
                $(that).parent().parent().find('.audit').text('通过')
                layer.msg('审核成功',{
                    title:'提示',
                    icon:6
                })
            }else{
                layer.msg('审核失败',{
                    title:'提示',
                    icon:4
                })
            }
        },'json');
    };
    $('.question_nopass').on('click',function () {
        var that=$(this);


        nopass(that);
        layer.close(index);

    });
    function nopass(that){
        var q_id=$(that).data('id');
        var url="{:url('question/nopass')}";
        var data={q_id:q_id};
        $.post(url,data,function (res) {
            if(res.status==1){
                $(that).parent().parent().find('.audit').text('不通过')
                layer.msg('审核成功',{
                    title:'提示',
                    icon:6
                })
            }else{
                layer.msg('审核失败',{
                    title:'提示',
                    icon:4
                })
            }
        },'json');
    };

    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function(index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', {
                icon: 5,
                time: 1000
            });
        });
    }
    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function(index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {
                icon: 6,
                time: 1000
            });
        });
    }
</script>
</body>
</html>